const mongoose = require('mongoose');

const schema = new mongoose.Schema({
    username: {
        type: String
    },
    password: {
        type: String,
        select: false, // 不查询
        set(val) {
            const bcrypt = require('bcryptjs');
            const salt = bcrypt.genSaltSync(10);
            return bcrypt.hashSync(val, salt);
        }
    }
});

module.exports = mongoose.model('Admin', schema);
